"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const express = require('express');
const jwt = require('jsonwebtoken');
const http = require('http');
const socketIo = require('socket.io');
const secretKey = 'your_secret_key';
const cors = require('cors');
const app = express();
const server = http.createServer(app);
const io = new socketIo.Server(server, {
    cors: {
        origin: 'http://localhost:5173', // 允许这个源
        methods: ['GET', 'POST'],
        allowedHeaders: ['my-custom-header'],
        credentials: true,
    }
});
io.on('connection', (socket) => {
    console.log('A user connected');
    socket.on('message', (data) => {
        console.log(data);
        io.emit('message', data);
    });
    // 服务器端监听客户端断开连接的事件
    socket.on('disconnect', () => {
        console.log('A user disconnected');
    });
});
server.listen(3000, () => {
    console.log('Listening on *:3000');
});
